package com.liyuhan.shopping.controller;

import com.alibaba.fastjson.JSONObject;
import com.liyuhan.shopping.dto.DataResponse;
import com.liyuhan.shopping.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    // 用户登录
    @RequestMapping("/login")
    public DataResponse login(@RequestBody JSONObject request){
        return userService.login(request);
    }

    // 用户注册
    @RequestMapping("/register")
    public DataResponse register(@RequestBody JSONObject request) {  // 直接将传入的数据转化为JSONObject类型（封装过的Map)
        // 传递给service层进行处理
        return userService.register(request);
    }
}
